package union_set


type Student struct {
	sfId     int
	bzhanId  int
	gitHubId int
}

func GetSameInstanceNum(students []interface{}) int{
	sfIdMap := map[int]interface{}{}
	bzhanIdMap := map[int]interface{}{}
	gitHubIdMap := map[int]interface{}{}
	myUnionSet := NewUnionSet(students)
	for _, student := range students {
		if s1, ok := sfIdMap[student.(Student).sfId]; ok {
			myUnionSet.Union(s1, student)
		} else {
			sfIdMap[student.(Student).sfId] = student
		}
		if s1, ok := bzhanIdMap[student.(Student).bzhanId]; ok {
			myUnionSet.Union(s1, student)
		} else {
			bzhanIdMap[student.(Student).bzhanId] = student
		}
		if s1, ok := gitHubIdMap[student.(Student).gitHubId]; ok {
			myUnionSet.Union(s1, student)
		} else {
			gitHubIdMap[student.(Student).gitHubId] = student
		}
	}
	return len(myUnionSet.SetSize)
}
